package cn.tedu.imop.content.dao.repository.impl;

import cn.tedu.imop.common.context.PageContext;
import cn.tedu.imop.common.pojo.PageData;
import cn.tedu.imop.common.utils.PageInfoToPageDataConverter;
import cn.tedu.imop.content.dao.mapper.ArticleCategoryMapper;
import cn.tedu.imop.content.dao.repository.ArticleCategoryRepository;
import cn.tedu.imop.content.entity.ArticleCategory;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Repository;

import java.util.Calendar;
import java.util.List;
@Repository
public class ArticleCategoryRepositoryImpl implements ArticleCategoryRepository {
    private final ArticleCategoryMapper articleCategoryMapper;
    public ArticleCategoryRepositoryImpl(ArticleCategoryMapper articleCategoryMapper) {
        this.articleCategoryMapper = articleCategoryMapper;
    }
    @Override
    public int insertArticleCategory(ArticleCategory articleCategory) {
        int rows=articleCategoryMapper.insert(articleCategory);
        return rows;
    }

    @Override
    public PageData<ArticleCategory> selectArticleCategoryList(ArticleCategory articleCategory) {
        PageContext.startPage();
        List<ArticleCategory> list=articleCategoryMapper.selectList(articleCategory);
        return PageInfoToPageDataConverter.convert(new PageInfo<>(list));
    }
    @Override
    public List<ArticleCategory> selectArticleCategoryList() {
        return articleCategoryMapper.selectList(new ArticleCategory());
    }
}
